/* HOME */
define(function() {
    return {
        go: function() {
            $loading();
            this.showFeed($e.data.posts);
        },
        showFeed: function(feed) {
            /* If there is no cached feed, we should probably fetch it... or tell the backend to fetch it */
            if(!feed) {
                var self = this;
                FB.api("me/home", {limit: 50}, function(res) {
                    $('#footer').hide();
                    self.showFeed(res);
                });
                return;
            }
            
            
            feed.data = postParser(feed.data);
            
            /* Template the data and show it */
            Template('posts', {posts: feed.data}, function(html) {
                $content.html(html);
                require(['posts'], function(posts) {
                    posts.listen();
                });
                feed.data.shift();
            }, ['likes','comments']);
        }
    };
});